from celery_tasks.sms.yuntongxun.ccp_sms import CCP
from celery_tasks.sms import constants
from celery_tasks.main import celery_app


@celery_app.task(bind=True, name='send_sms_code', retry_backoff=3)
def send_sms_code(self, mobile, sms_code):
    try:
        send_ret = CCP().send_template_sms(mobile, [sms_code, constants.SMS_VERIFY_CODE_EXPIRES // 60], constants.SMS_TEMPLATE_ID)
    except Exception as e:
        raise self.retry(exc=e, max_retries=3)

    return send_ret
